package br.com.educa.service;

import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import br.com.educa.modelo.security.Menu;


@Service
@Transactional
public class MenuServiceImpl implements MenuService {

	public long countAllMenus() {
        return Menu.countMenus();
    }

	public void deleteMenu(Menu menu) {
        menu.remove();
    }

	public Menu findMenu(Long id) {
        return Menu.findMenu(id);
    }

	public List<Menu> findAllMenus() {
        return Menu.findAllMenus();
    }

	public List<Menu> findMenuEntries(int firstResult, int maxResults) {
        return Menu.findMenuEntries(firstResult, maxResults);
    }

	public void saveMenu(Menu menu) {
        menu.persist();
    }

	public Menu updateMenu(Menu menu) {
        return menu.merge();
    }

	@Override
	public List<Menu> findAllMenusChildren(Menu pai) {
		return pai.getFilhos();
	}

	
}
